home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 52
/
Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso
/
Aminet
/
util
/
rexx
/
QuickMsg.lha
/
QuickMsg
/
English
/
QuickMsg.rexx
< prev
Wrap
OS/2 REXX Batch file
|
2002-09-26
|
7KB
|
293 lines
/* $VER: QuickMsg.rexx 1.0 (26-Sep-2002) English by A. Greve */
SIGNAL ON break_c
SIGNAL ON failure
SIGNAL ON halt
SIGNAL ON ioerr
SIGNAL ON syntax
tri = 0
quo = '22'x; apo = '27'x
PARSE ARG Msg
IF Msg = '?' THEN SIGNAL Templates
KeyW = UPPER(WORD(Msg, 1))
IF (KeyW == 'FROM') | (KeyW == 'FILE') THEN DO
IF LEFT(WORD(Msg, 2), 1) == quo THEN DO
p1 = 0; p2 = 0
DO i = 6 FOR LENGTH(Msg)
IF SUBSTR(Msg, i, 1) == quo THEN DO
p1 = i; LEAVE
END
END
DO i = p1 + 1 FOR LENGTH(Msg)
IF SUBSTR(Msg, i, 1) == quo THEN DO
p2 = i; LEAVE
END
END
IF p1 == 0 | p2 == 0 | (p2 - p1) <= 0 THEN DO
SAY 'QuickMsg: Parsing the filename failed!'
EXIT(0)
END
FName = SUBSTR(Msg, p1 + 1, p2 - p1 - 1)
END
ELSE DO
FName = WORD(Msg, 2)
p2 = WORDINDEX(Msg, 2) + LENGTH(FName) - 1
END
IF OPEN('RBuffer', FName, 'R') THEN DO
IF KeyW == 'FROM' THEN DO
Msg = READLN('RBuffer')
CLOSE('RBuffer')
END
ELSE DO
i = 0; il = 0
DO UNTIL EOF('RBuffer')
i = i + 1
FileIn.i = READLN('RBuffer')
il = MAX(il, LENGTH(FileIn.i))
END
CLOSE('RBuffer')
MsgH = ''
IF i > 1 THEN DO
DO ih = 1 TO i
FileIn.ih = FileIn.ih || COPIES(' ', il - LENGTH(FileIn.ih)) || '\n'
END
FileIn.ih = LEFT(FileIn.ih, LENGTH(FileIn.ih) - 2)
IF STRIP(FileIn.ih) == '' THEN DO
FileIn.ih = ''
ih = ih - 1
FileIn.ih = LEFT(FileIn.ih, LENGTH(FileIn.ih) - 2)
IF STRIP(FileIn.ih) == '' THEN FileIn.ih = ''
END
DO ih = 1 TO i
IF FileIn.ih ~= '' THEN DO
Flag = 1
IF ih = i THEN Flag = LENGTH(TRIM(LEFT(FileIn.ih, LENGTH(FileIn.ih) - 2)))
IF Flag > 0 THEN MsgH = MsgH || FileIn.ih
END
END
MsgH = LEFT(MsgH, LENGTH(MsgH) - 2)
END
ELSE MsgH = FileIn.1
IF RIGHT(MsgH, 1) == ' ' THEN MsgH = OVERLAY('a0'x, MsgH, LENGTH(MsgH))
Msg = DELSTR(Msg, 1, p2)
Msg = INSERT(MsgH, Msg, 0)
DROP FileIn. MsgH
END
END
ELSE DO
SAY 'QuickMsg: Could not open »'FName'« !'
EXIT(0)
END
END
w = WORDS(Msg); pd = LENGTH(Msg); pp = pd; pm = pd; pw = pd; ph = pd
DO i = 1 FOR w
j = WORD(Msg, i); pj = WORDINDEX(Msg, i); k = LEFT(j, 2)
IF UPPER(k) == 'M=' THEN DO
m1 = RIGHT(j, LENGTH(j) - 2)
IF DATATYPE(m1, 'w') THEN DO
ChMode = m1
pm = WORDINDEX(Msg, i) - 1
END
END
IF UPPER(k) == 'D=' THEN DO
k1 = RIGHT(j, LENGTH(j) - 2)
IF DATATYPE(k1, 'w') THEN DO
DelSecs = k1
pd = WORDINDEX(Msg, i) - 1
END
END
IF UPPER(k) == 'P=' THEN DO
pj1 = pj + 2
IF SUBSTR(Msg, pj1, 1) = quo THEN DO
pj2 = 0
DO ih = pj1 + 1 FOR pd
IF SUBSTR(Msg, ih, 1) == quo THEN DO
pj2 = ih - 1; LEAVE
END
END
IF pj2 > pj1 THEN DO
PubScreen = SUBSTR(Msg, pj1 + 1, pj2 - pj1)
pp = pj1 - 3
END
END
ELSE DO
PubScreen = RIGHT(j, LENGTH(j) - 2)
pp = WORDINDEX(Msg, i) - 2
END
END
IF UPPER(k) == 'W=' THEN DO
w1 = RIGHT(j, LENGTH(j) - 2)
IF DATATYPE(w1, 'w') THEN DO
MaxW = w1
pw = WORDINDEX(Msg, i) - 1
END
END
IF UPPER(k) == 'H=' THEN DO
h1 = RIGHT(j, LENGTH(j) - 2)
IF DATATYPE(h1, 'w') THEN DO
MaxH = h1
ph = WORDINDEX(Msg, i) - 1
END
END
END
p = MIN(pd, pp, pm, pw, ph)
IF p < LENGTH(Msg) THEN Msg = TRIM(LEFT(Msg, p))
IF DelSecs == 'DELSECS' | DelSecs <= 0 THEN DelSecs = 2
IF ChMode == 'CHMODE' | ChMode < 0 | ChMode > 4 THEN ChMode = 0
IF MaxW == 'MAXW' | MaxW < 0 THEN MaxW = 0
IF MaxH == 'MAXH' | MaxH < 0 THEN MaxH = 0
Buffer = Msg
i1 = LENGTH(Msg)
IF i1 > 0 THEN DO
DO i = 1 FOR i1
IF SUBSTR(Msg, i, 1) == quo THEN Msg = OVERLAY(apo, Msg, i, 1)
END
END
i = 1
DO FOREVER
j = INDEX(Msg, '\n')
IF j > 0 THEN DO
MsgY.i = LEFT(Msg, j - 1)
Msg = RIGHT(Msg, LENGTH(Msg) - j - 1)
i = i + 1
END
ELSE DO
MsgY.i = Msg; LEAVE
END
END
IF MaxW ~= 0 THEN DO
jh = 0
DO j = 1 FOR i
jh = jh + 1
tmp = MsgY.j
DO FOREVER
IF LENGTH(tmp) > MaxW THEN DO
MsgX.jh = LEFT(tmp, MaxW)
tmp = RIGHT(tmp, LENGTH(tmp) - MaxW)
jh = jh + 1
END
ELSE DO
MsgX.jh = tmp; LEAVE
END
END
END
i = jh
END
ELSE DO
DO j = 1 FOR i
MsgX.j = MsgY.j
END
END
DROP MsgY.
IF MaxH ~= 0 THEN i = MIN(i, MaxH)
CALL SetAppInfo()
wintags_t = ''
DO j = 1 FOR i
SELECT
WHEN ChMode = 0 THEN wintags_t = wintags_t || ' 'TextN(' 'MsgX.j' ')' '
WHEN ChMode = 1 THEN wintags_t = wintags_t || ' 'TextH(' 'MsgX.j' ')' '
WHEN ChMode = 2 THEN wintags_t = wintags_t || ' 'TextB(' 'MsgX.j' ')' '
WHEN ChMode = 3 THEN wintags_t = wintags_t || ' 'Text3(' 'MsgX.j' ')' '
WHEN ChMode = 4 THEN wintags_t = wintags_t || ' 'TextT(' 'MsgX.j' ')' '
OTHERWISE
END
END
IF ~SHOW('L', 'tritonrexx.library') THEN DO
IF ~ADDLIB('tritonrexx.library', 10, -30, 0) THEN DO
SAY Buffer
EXIT(0)
END
END
IF ~SHOW('L', 'rexxsupport.library') THEN DO
IF ~ADDLIB('rexxsupport.library', 10, -30, 0) THEN DO
SAY Buffer
EXIT(0)
END
END
tri = 1
app = NULL()
wintags_a = WindowID(1),
WindowFlags('TRWF_NODRAGBAR|TRWF_NODEPTHGADGET|TRWF_NOCLOSEGADGET|TRWF_NOZIPGADGET|TRWF_NOSIZEGADGET|TRWF_NOMINTEXTWIDTH'),
WindowPosition('TRWP_CENTERDISPLAY'),
PubScreenName(PubScreen),
'VertGroupC',
'Space'
wintags_e = 'Space',
'EndGroup',
'EndProject'
app = TR_CREATEAPP('TRCA_Name' '"'appname'"',
'TRCA_LongName' '"'applongname'"',
'TRCA_Info' '"'appinfo'"',
'TRCA_Version' '"'appversion'"',
'TRCA_Release' '"'apprelease'"',
'TRCA_Date' '"'appdate'"',
'TAG_END')
IF app ~= NULL() THEN window = TR_OPENPROJECT(app, wintags_a || wintags_t || wintags_e)
IF window ~= NULL() THEN DO
CALL DELAY(DelSecs * 50)
CALL TR_CLOSEPROJECT(window)
END
ELSE SAY Buffer
CALL TR_DELETEAPP(app)
IF tri THEN CALL DELETE('ENV:Triton/QuickMsg.win.1')
EXIT(0)
SetAppInfo:
appname = 'QuickMsg'
applongname = 'QuickMsg ENG - ©2002 von Axel Greve'
appinfo = 'Shows a quick message on the desired PubScreen'
appversion = '1.0'
apprelease = '1'
appdate = '26-Sep-2002'
RETURN 0
Templates:
CALL SetAppInfo()
SAY appname'.rexx 'appversion' ('appdate') - 'appinfo
SAY 'This program can be called in 3 different ways:'
SAY '1.) rx QuickMsg.rexx <Text> [D=<Seconds>] [P=<PubScreen>] [M=<Textformat>] [W=<Width>] [H=<Height>]'
SAY '2.) rx QuickMsg.rexx FILE <Filename> [D=<Seconds>] [P=<PubScreen>] [M=<Textformat>] [W=<Width>] [H=<Height>]'
SAY '3.) rx QuickMsg.rexx FROM <Filename>'
SAY 'Where:'
SAY ' <Text> = The text to be displayed (String) f. ex. Couldn''t find file!'
SAY ' <Filename> = Path and filename (String) f. ex. FILE t:tempfile'
SAY ' <Filename> = Path and filename (String) f. ex. FROM 'quo't:temp file'quo
SAY ' <Seconds> = Display time in seconds (Integer) f. ex. D=5'
SAY ' <PubScreen> = Name of PubScreen (String) f. ex. P=Workbench'
SAY ' <PubScreen> = Name of PubScreen (String) f. ex. P='quo'Test Screen'quo
SAY ' <Textformat> = See description (Integer) f. ex. M=2'
SAY ' <Width> = Max. textwidth in columns (Integer) f. ex. W=20'
SAY ' <Height> = Max. textheight in lines (Integer) f. ex. H=5'
SAY '<Text> or FILE <Filename> always must be the first argument, the further'
SAY 'arguments are optional and their order is unimportant. Leaving out all'
SAY 'arguments will open an empty window on the Workbench screen for 2 seconds.'
EXIT(0)
break_c:
failure:
halt:
ioerr:
syntax:
SAY '+++ Error 'rc' in line 'sigl' - 'ERRORTEXT(rc)
SAY SOURCELINE(sigl)
IF app ~= '00000000'x THEN CALL TR_DELETEAPP(app)
EXIT(10)